// 不使用 代理模式的图片预加载

var MyImage = (function(){
    var imgNode = document.createElement('img')
    document.body.appendChild(imgNode)
    var img = new Image
    img.onload=function(){
        imgNode.src = img.src
    }
    return {
        setSrc : function (src) {
            imgNode.src = 'loading.webp'
            img.src=src
        }
    }
})()
MyImage.setSrc('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fnimg.ws.126.net%2F%3Furl%3Dhttp%253A%252F%252Fdingyue.ws.126.net%252F2021%252F0604%252Fcf462b52j00qu4yit0018c000hs00npc.jpg%26thumbnail%3D650x2147483647%26quality%3D80%26type%3Djpg&refer=http%3A%2F%2Fnimg.ws.126.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1649057698&t=28ac82cb6284c60a0a63b8b4428f5a43')